<?php

    header('Content-type:text/html;charset=utf-8');

    //连接认证
    //服务器地址:localhost:3306 或者127.0.0.1都可以
    //mysql_connect('localhost:3306','root','root') or die('MySQL link fail! exit');
    if(($link = mysql_connect('127.0.0.1','Mango','mangoc++11')))//和上述写法等价
        echo "MySQL link success <hr/>";
    else 
        die('MySQL link fail! exit');

    //设定字符集
    if(mysql_query('set names utf8',$link))
        echo "charset set:utf8  success!<hr/>";
    else 
        echo "charset set:utf8  fail!<hr/>";

    //选择使用的数据库
    if(mysql_query('use test'))
        echo "database test choice success <hr/>";
    else 
        echo "database test choice fail <hr/>";
        
    echo "MySQL init success!".'<hr/>'; 